/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
package robocup.component.speechacts.coachlanguage;

import java.util.LinkedList;

public class Region {

	private TypeConstants.REGIONTYPE regionType = TypeConstants.REGIONTYPE.INIT;

	private String regionName = "";

	private CPoint point = null;

	private CPoint recPoint1 = null;

	private CPoint recPoint2 = null;

	private CPoint triPoint1 = null;

	private CPoint triPoint2 = null;

	private CPoint triPoint3 = null;

	private CPoint quadPoint1 = null;

	private CPoint quadPoint2 = null;

	private CPoint quadPoint3 = null;

	private CPoint quadPoint4 = null;

	private CPoint arcPoint = null;

	private double arcReal1 = 0;

	private double arcReal2 = 0;

	private double arcReal3 = 0;

	private double arcReal4 = 0;

	private LinkedList<Region> regionList = new LinkedList<Region>();

	public void addRegion(Region region) {
		this.regionList.add(region);
		regionType = TypeConstants.REGIONTYPE.REG;

	}

	public String getRegionName() {
		return regionName;
	}

	public void setRegionName(String regionName) {
		this.regionName = regionName;
		regionType = TypeConstants.REGIONTYPE.NAME;
	}

	public TypeConstants.REGIONTYPE getRegionType() {
		return regionType;
	}

	public void setRegionType(TypeConstants.REGIONTYPE regionType) {
		this.regionType = regionType;
	}

	public void setNull() {
		regionType = TypeConstants.REGIONTYPE.NULL;
	}

	public CPoint getPoint() {
		return point;
	}

	public void setPoint(CPoint point) {
		this.point = point;
		regionType = TypeConstants.REGIONTYPE.POINT;
	}

	public CPoint getArcPoint() {
		return arcPoint;
	}

	public void setArcPoint(CPoint arcPoint) {
		this.arcPoint = arcPoint;
		regionType = TypeConstants.REGIONTYPE.ARC;
	}

	public double getArcReal1() {
		return arcReal1;
	}

	public void setArcReal1(double arcReal1) {
		this.arcReal1 = arcReal1;
		regionType = TypeConstants.REGIONTYPE.ARC;
	}

	public double getArcReal2() {
		return arcReal2;
	}

	public void setArcReal2(double arcReal2) {
		this.arcReal2 = arcReal2;
		regionType = TypeConstants.REGIONTYPE.ARC;
	}

	public double getArcReal3() {
		return arcReal3;
	}

	public void setArcReal3(double arcReal3) {
		this.arcReal3 = arcReal3;
		regionType = TypeConstants.REGIONTYPE.ARC;
	}

	public double getArcReal4() {
		return arcReal4;
	}

	public void setArcReal4(double arcReal4) {
		this.arcReal4 = arcReal4;
		regionType = TypeConstants.REGIONTYPE.ARC;
	}

	public CPoint getRecPoint1() {
		return recPoint1;
	}

	public void setRecPoint1(CPoint recPoint1) {
		this.recPoint1 = recPoint1;
		regionType = TypeConstants.REGIONTYPE.REC;
	}

	public CPoint getRecPoint2() {
		return recPoint2;
	}

	public void setRecPoint2(CPoint recPoint2) {
		this.recPoint2 = recPoint2;
		regionType = TypeConstants.REGIONTYPE.REC;
	}

	public CPoint getTriPoint1() {
		return triPoint1;
	}

	public void setTriPoint1(CPoint triPoint1) {
		this.triPoint1 = triPoint1;
		regionType = TypeConstants.REGIONTYPE.TRI;
	}

	public CPoint getTriPoint2() {
		return triPoint2;
	}

	public void setTriPoint2(CPoint triPoint2) {
		this.triPoint2 = triPoint2;
		regionType = TypeConstants.REGIONTYPE.TRI;
	}

	public CPoint getTriPoint3() {
		return triPoint3;
	}

	public void setTriPoint3(CPoint triPoint3) {
		this.triPoint3 = triPoint3;
		regionType = TypeConstants.REGIONTYPE.TRI;
	}

	public LinkedList<Region> getRegionList() {
		return regionList;
	}

	public void setRegionList(LinkedList<Region> regionList) {
		this.regionList = regionList;
		regionType = TypeConstants.REGIONTYPE.REG;
	}

	public CPoint getQuadPoint1() {
		return quadPoint1;
	}

	public void setQuadPoint1(CPoint quadPoint1) {
		this.quadPoint1 = quadPoint1;
		regionType = TypeConstants.REGIONTYPE.QUAD;
	}

	public CPoint getQuadPoint2() {
		return quadPoint2;
	}

	public void setQuadPoint2(CPoint quadPoint2) {
		this.quadPoint2 = quadPoint2;
		regionType = TypeConstants.REGIONTYPE.QUAD;
	}

	public CPoint getQuadPoint3() {
		return quadPoint3;
	}

	public void setQuadPoint3(CPoint quadPoint3) {
		this.quadPoint3 = quadPoint3;
		regionType = TypeConstants.REGIONTYPE.QUAD;
	}

	public CPoint getQuadPoint4() {
		return quadPoint4;
	}

	public void setQuadPoint4(CPoint quadPoint4) {
		this.quadPoint4 = quadPoint4;
		regionType = TypeConstants.REGIONTYPE.QUAD;
	}

	public String toString() {
		StringBuffer buf = new StringBuffer();

		switch (this.regionType) {

		case INIT:
			buf.append("(empty region)");
			break;

		case NAME:
			buf.append(this.regionName);
			break;

		case NULL:
			buf.append("(null)");
			break;

		case ARC:
			buf.append("(arc " + this.arcPoint.toString());
			buf.append(" " + this.arcReal1);
			buf.append(" " + this.arcReal2);
			buf.append(" " + this.arcReal3);
			buf.append(" " + this.arcReal4 + ")");
			break;

		case REG:
			buf.append("(reg");

			for (Region reg : this.regionList)
				buf.append(" " + reg.toString());

			buf.append(")");
			break;

		case REC:
			buf.append("(rec");
			buf.append(" " + this.recPoint1.toString());
			buf.append(" " + this.recPoint2.toString() + ")");
			break;

		case TRI:
			buf.append("(tri");
			buf.append(" " + this.triPoint1.toString());
			buf.append(" " + this.triPoint2.toString());
			buf.append(" " + this.triPoint3.toString() + ")");
			break;

		case QUAD:
			buf.append("(quad");
			buf.append(" " + this.quadPoint1.toString());
			buf.append(" " + this.quadPoint2.toString());
			buf.append(" " + this.quadPoint3.toString());
			buf.append(" " + this.quadPoint4.toString() + ")");
			break;

		case POINT:
			buf.append(this.point.toString());
			break;
		}

		return buf.toString();

	}

}
